//
//  AloneInTheLightViewController.h
//  AloneInTheLight
//
//  Created by Michael Sherron on 9/20/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "RotationGestureView.h"
#import "chipmunk_private.h"
#import "SoundController.h"
#include <mach/mach_time.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

@class RotationGestureView;

@interface AloneInTheLightViewController : UIViewController
{
    cpSpace *space;
    cpShape *bearShape;
    cpShape *iceFloatShape;
    cpBody *bearBody;
    cpBody *iceFloatBody;
    int counter;
    UIImageView *xcodeImageView;
}

#define FLUID_DENSITY 0.00014
#define FLUID_DRAG 2.0
#define GRABABLE_MASK_BIT (1<<31)
#define NOT_GRABABLE_MASK (~GRABABLE_MASK_BIT)

@property (nonatomic, assign) BOOL gesturesOn;

@property (nonatomic, assign) uint64_t previousTime;    //a high precision variable used to keep track of time
@property (nonatomic, assign) double elapsedTime;  //the time that has passed since the last game loop
@property (nonatomic, assign) double conversionToSeconds;  //a variable used to hold the conversion factor from "ticks" reported by the mach functions into seconds

@property (nonatomic, assign) BOOL shardAnimation;

@property (nonatomic, retain) UILabel *FPSLabel;

@property (nonatomic, assign) NSInteger bearXVelocity;
@property (nonatomic, assign) NSInteger bearYVelocity;

@property (nonatomic, assign) NSInteger bearDrawPosition;

@property (nonatomic, retain) UIImageView *bearGraphic;
@property (nonatomic, retain) UIImageView *icefloatGraphic;
@property (nonatomic, retain) UIImageView *shard;

@property (nonatomic, retain) NSMutableArray *parallaxLayers;

@property (nonatomic, assign) BOOL bearTravelingRight;

@property (nonatomic, retain) UIView *snowView;
@property (nonatomic, retain) UIView *iceView;
@property (nonatomic, retain) UIView *mountainView;
@property (nonatomic, retain) UIView *waterView;
@property (nonatomic, retain) UIView *interactionLayer;

@property (nonatomic, retain) RotationGestureView *rotationGesture;

@property (nonatomic, retain) NSMutableArray *gestureArray;

@property (nonatomic, retain) SoundController *soundController;

- (void)toggleGesturesOff;
- (void)toggleGesturesOn;
- (void)setupChipmunk;
- (void)tick:(NSTimer *)timer;
-(void)renderViewInSpace:(UIView*)view atPos:(cpVect)atPos withRotAngleInRadians:(cpFloat)withRotAngleInRadians;
static cpBool waterPreSolve(cpArbiter *arb, cpSpace *space, void *ptr);
static cpFloat k_scalar_body(cpBody *body, cpVect r, cpVect n);


@end
